home *** CD-ROM | disk | FTP | other *** search
/ 9-Digit Zip Code Directory / 9-Digit Zip Code Directory (American Business Information) (ABIZIP-12).ISO / z4src.zip / SCODE.H < prev    next >
C/C++ Source or Header  |  1993-11-16  |  11KB  |  284 lines

  1. /*****************************************************************************\
  2. *                                                                             *
  3. * scode.h -     Defines standard status code services.                          *
  4. *                                                                             *
  5. *               OLE Version 2.0                                               *
  6. *                                                                             *
  7. *               Copyright (c) 1992-1993, Microsoft Corp. All rights reserved. *
  8. *                                                                             *
  9. \*****************************************************************************/
  10.  
  11.  
  12. #ifndef __SCODE_H__
  13. #define __SCODE_H__
  14.  
  15. //
  16. // SCODE
  17. //
  18.  
  19. typedef long SCODE;
  20. typedef SCODE *PSCODE;
  21. typedef void FAR * HRESULT;
  22. #define NOERROR 0
  23.  
  24. //
  25. //  Status values are 32 bit values layed out as follows:
  26. //
  27. //   3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
  28. //   1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
  29. //  +-+---------------------+-------+-------------------------------+
  30. //  |S|       Context       | Facil |               Code            |
  31. //  +-+---------------------+-------+-------------------------------+
  32. //
  33. //  where
  34. //
  35. //      S - is the severity code
  36. //
  37. //          0 - Success
  38. //          1 - Error
  39. //
  40. //      Context - context info
  41. //
  42. //      Facility - is the facility code
  43. //
  44. //      Code - is the facility's status code
  45. //
  46.  
  47. //
  48. // Severity values
  49. //
  50.  
  51. #define SEVERITY_SUCCESS    0
  52. #define SEVERITY_ERROR      1
  53.  
  54.  
  55.  
  56. #define SUCCEEDED(Status) ((SCODE)(Status) >= 0)
  57.  
  58. #define FAILED(Status) ((SCODE)(Status)<0)
  59.  
  60.  
  61. //
  62. // Return the code
  63. //
  64.  
  65. #define SCODE_CODE(sc)      ((sc) & 0xFFFF)
  66.  
  67. //
  68. //  Return the facility
  69. //
  70.  
  71. #define SCODE_FACILITY(sc)  (((sc) >> 16) & 0x1fff)
  72.  
  73. //
  74. //  Return the severity
  75. //
  76.  
  77. #define SCODE_SEVERITY(sc)  (((sc) >> 31) & 0x1)
  78.  
  79. //
  80. // Create an SCODE value from component pieces
  81. //
  82.  
  83. #define MAKE_SCODE(sev,fac,code) \
  84.     ((SCODE) (((unsigned long)(sev)<<31) | ((unsigned long)(fac)<<16) | ((unsigned long)(code))) )
  85.  
  86.  
  87.  
  88. // --------------------- Functions ---------------------------------------
  89.  
  90. #define GetScode(hr)        ((SCODE)(hr) & 0x800FFFFF)
  91. #define ResultFromScode(sc) ((HRESULT)((SCODE)(sc) & 0x800FFFFF))
  92.  
  93. STDAPI PropagateResult(HRESULT hrPrev, SCODE scNew);
  94.  
  95.  
  96. // -------------------------- Facility definitions -------------------------
  97.  
  98. #define FACILITY_NULL       0x0000 // generally useful errors ([SE]_*)
  99. #define FACILITY_RPC            0x0001 // remote procedure call errors (RPC_E_*)
  100. #define FACILITY_DISPATCH   0x0002 // late binding dispatch errors
  101. #define FACILITY_STORAGE   0x0003 // storage errors (STG_E_*)
  102. #define FACILITY_ITF            0x0004 // interface-specific errors
  103.  
  104.  
  105.  
  106. #define S_OK                0L
  107. #define S_FALSE             MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_NULL, 1)
  108.  
  109.  
  110.  
  111. // --------------------- FACILITY_NULL errors ------------------------------
  112.  
  113. #define E_UNEXPECTED        MAKE_SCODE(SEVERITY_ERROR,   FACILITY_NULL, 0xffff)
  114.                             // relatively catastrophic failure
  115.  
  116. #define E_NOTIMPL           MAKE_SCODE(SEVERITY_ERROR,   FACILITY_NULL, 1)
  117.                             // not implemented
  118.  
  119. #define E_OUTOFMEMORY       MAKE_SCODE(SEVERITY_ERROR,   FACILITY_NULL, 2)
  120.                             // ran out of memory
  121.  
  122. #define E_INVALIDARG        MAKE_SCODE(SEVERITY_ERROR,   FACILITY_NULL, 3)
  123.                             // one or more arguments are invalid
  124.  
  125. #define E_NOINTERFACE       MAKE_SCODE(SEVERITY_ERROR,   FACILITY_NULL, 4)
  126.                             // no such interface supported
  127.  
  128.  
  129. #define E_POINTER           MAKE_SCODE(SEVERITY_ERROR,   FACILITY_NULL, 5)
  130.                             // invalid pointer
  131.  
  132. #define E_HANDLE            MAKE_SCODE(SEVERITY_ERROR,   FACILITY_NULL, 6)
  133.                             // invalid handle
  134.  
  135. #define E_ABORT             MAKE_SCODE(SEVERITY_ERROR,   FACILITY_NULL, 7)
  136.                             // operation aborted
  137.  
  138. #define E_FAIL              MAKE_SCODE(SEVERITY_ERROR,   FACILITY_NULL, 8)
  139.                             // unspecified error
  140.  
  141.  
  142. #define E_ACCESSDENIED      MAKE_SCODE(SEVERITY_ERROR,   FACILITY_NULL, 9)
  143.                             // general access denied error
  144.  
  145.  
  146. // ----------------- FACILITY_ITF errors used by OLE ---------------------
  147. //
  148. // By convention, OLE interfaces divide the FACILITY_ITF range of errors
  149. // into nonoverlapping subranges.  If an OLE interface returns a FACILITY_ITF 
  150. // scode, it must be from the range associated with that interface or from
  151. // the shared range: OLE_E_FIRST...OLE_E_LAST.
  152. //
  153. // The ranges, their associated interfaces, and the header file that defines
  154. // the actual scodes are given below.
  155. // 
  156.  
  157. // Generic OLE errors that may be returned by many interfaces
  158. #define OLE_E_FIRST MAKE_SCODE(SEVERITY_ERROR,   FACILITY_ITF, 0x0000)
  159. #define OLE_E_LAST  MAKE_SCODE(SEVERITY_ERROR,   FACILITY_ITF, 0x00FF)
  160. #define OLE_S_FIRST MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x0000)
  161. #define OLE_S_LAST  MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x00FF)
  162. // interfaces: all
  163. // file: ole2.h
  164.  
  165.  
  166. #define DRAGDROP_E_FIRST    MAKE_SCODE(SEVERITY_ERROR,   FACILITY_ITF, 0x0100)
  167. #define DRAGDROP_E_LAST     MAKE_SCODE(SEVERITY_ERROR,   FACILITY_ITF, 0x010F)
  168. #define DRAGDROP_S_FIRST    MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x0100)
  169. #define DRAGDROP_S_LAST     MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x010F)
  170. // interfaces: IDropSource, IDropTarget
  171. // file: ole2.h
  172.  
  173. #define CLASSFACTORY_E_FIRST MAKE_SCODE(SEVERITY_ERROR,   FACILITY_ITF, 0x0110)
  174. #define CLASSFACTORY_E_LAST  MAKE_SCODE(SEVERITY_ERROR,   FACILITY_ITF, 0x011F)
  175. #define CLASSFACTORY_S_FIRST MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x0110)
  176. #define CLASSFACTORY_S_LAST  MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x011F)
  177. // interfaces: IClassFactory
  178. // file:
  179.  
  180. #define MARSHAL_E_FIRST MAKE_SCODE(SEVERITY_ERROR,   FACILITY_ITF, 0x0120)
  181. #define MARSHAL_E_LAST  MAKE_SCODE(SEVERITY_ERROR,   FACILITY_ITF, 0x012F)
  182. #define MARSHAL_S_FIRST MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x0120)
  183. #define MARSHAL_S_LAST  MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x012F)
  184. // interfaces: IMarshal, IStdMarshalInfo, marshal APIs
  185. // file:
  186.  
  187. #define DATA_E_FIRST    MAKE_SCODE(SEVERITY_ERROR,   FACILITY_ITF, 0x0130)
  188. #define DATA_E_LAST     MAKE_SCODE(SEVERITY_ERROR,   FACILITY_ITF, 0x013F)
  189. #define DATA_S_FIRST    MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x0130)
  190. #define DATA_S_LAST     MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x013F)
  191. // interfaces: IDataObject
  192. // file: dvobj.h
  193.  
  194. #define VIEW_E_FIRST    MAKE_SCODE(SEVERITY_ERROR,   FACILITY_ITF, 0x0140)
  195. #define VIEW_E_LAST     MAKE_SCODE(SEVERITY_ERROR,   FACILITY_ITF, 0x014F)
  196. #define VIEW_S_FIRST    MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x0140)
  197. #define VIEW_S_LAST     MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x014F)
  198. // interfaces: IViewObject
  199. // file: dvobj.h
  200.  
  201. #define REGDB_E_FIRST   MAKE_SCODE(SEVERITY_ERROR,   FACILITY_ITF, 0x0150)
  202. #define REGDB_E_LAST    MAKE_SCODE(SEVERITY_ERROR,   FACILITY_ITF, 0x015F)
  203. #define REGDB_S_FIRST   MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x0150)
  204. #define REGDB_S_LAST    MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x015F)
  205. // API: reg.dat manipulation
  206. // file: 
  207.  
  208.  
  209. // range 160 - 16F reserved
  210.  
  211. #define CACHE_E_FIRST   MAKE_SCODE(SEVERITY_ERROR,   FACILITY_ITF, 0x0170) 
  212. #define CACHE_E_LAST    MAKE_SCODE(SEVERITY_ERROR,   FACILITY_ITF, 0x017F)
  213. #define CACHE_S_FIRST   MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x0170)
  214. #define CACHE_S_LAST    MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x017F)
  215. // interfaces: IOleCache
  216. // file:
  217.  
  218. #define OLEOBJ_E_FIRST  MAKE_SCODE(SEVERITY_ERROR,   FACILITY_ITF, 0x0180)
  219. #define OLEOBJ_E_LAST   MAKE_SCODE(SEVERITY_ERROR,   FACILITY_ITF, 0x018F)
  220. #define OLEOBJ_S_FIRST  MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x0180)
  221. #define OLEOBJ_S_LAST   MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x018F)
  222. // interfaces: IOleObject
  223. // file:
  224.  
  225. #define CLIENTSITE_E_FIRST  MAKE_SCODE(SEVERITY_ERROR,   FACILITY_ITF, 0x0190) 
  226. #define CLIENTSITE_E_LAST  MAKE_SCODE(SEVERITY_ERROR,   FACILITY_ITF, 0x019F)
  227. #define CLIENTSITE_S_FIRST MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x0190)
  228. #define CLIENTSITE_S_LAST   MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x019F)
  229. // interfaces: IOleClientSite
  230. // file:
  231.  
  232. #define INPLACE_E_FIRST MAKE_SCODE(SEVERITY_ERROR,   FACILITY_ITF, 0x01A0)
  233. #define INPLACE_E_LAST  MAKE_SCODE(SEVERITY_ERROR,   FACILITY_ITF, 0x01AF)
  234. #define INPLACE_S_FIRST MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x01A0)
  235. #define INPLACE_S_LAST  MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x01AF)
  236. // interfaces: IOleWindow, IOleInPlaceObject, IOleInPlaceActiveObject,
  237. //                 IOleInPlaceUIWindow, IOleInPlaceFrame, IOleInPlaceSite
  238. // file:
  239.  
  240. #define ENUM_E_FIRST        MAKE_SCODE(SEVERITY_ERROR,   FACILITY_ITF, 0x01B0)
  241. #define ENUM_E_LAST     MAKE_SCODE(SEVERITY_ERROR,   FACILITY_ITF, 0x01BF)
  242. #define ENUM_S_FIRST    MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x01B0)
  243. #define ENUM_S_LAST     MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x01BF)
  244. // interfaces: IEnum*
  245. // file:
  246.  
  247. #define CONVERT10_E_FIRST   MAKE_SCODE(SEVERITY_ERROR,   FACILITY_ITF, 0x01C0)
  248. #define CONVERT10_E_LAST   MAKE_SCODE(SEVERITY_ERROR,   FACILITY_ITF, 0x01CF)
  249. #define CONVERT10_S_FIRST  MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x01C0)
  250. #define CONVERT10_S_LAST   MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x01CF)
  251. // API: OleConvertOLESTREAMToIStorage, OleConvertIStorageToOLESTREAM
  252. // file:
  253.  
  254.  
  255. #define CLIPBRD_E_FIRST     MAKE_SCODE(SEVERITY_ERROR,   FACILITY_ITF, 0x01D0)
  256. #define CLIPBRD_E_LAST      MAKE_SCODE(SEVERITY_ERROR,   FACILITY_ITF, 0x01DF)
  257. #define CLIPBRD_S_FIRST     MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x01D0)
  258. #define CLIPBRD_S_LAST      MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x01DF)
  259. // interfaces: OleSetClipboard, OleGetClipboard, OleFlushClipboard
  260. // file: ole2.h
  261.  
  262. #define MK_E_FIRST      MAKE_SCODE(SEVERITY_ERROR,   FACILITY_ITF, 0x01E0)
  263. #define MK_E_LAST           MAKE_SCODE(SEVERITY_ERROR,   FACILITY_ITF, 0x01EF)
  264. #define MK_S_FIRST          MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x01E0)
  265. #define MK_S_LAST           MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x01EF)
  266. // interfaces: IMoniker, IBindCtx, IRunningObjectTable, IParseDisplayName,
  267. //             IOleContainer, IOleItemContainer, IOleLink
  268. // file: moniker.h
  269.  
  270.  
  271. #define CO_E_FIRST      MAKE_SCODE(SEVERITY_ERROR,   FACILITY_ITF, 0x01F0)
  272. #define CO_E_LAST           MAKE_SCODE(SEVERITY_ERROR,   FACILITY_ITF, 0x01FF)
  273. #define CO_S_FIRST          MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x01F0)
  274. #define CO_S_LAST           MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x01FF)
  275. // all Co* API
  276. // file: compobj.h
  277.  
  278.  
  279. // range 200 - ffff for new error codes
  280.  
  281.  
  282.  
  283. #endif      // ifndef __SCODE_H__
  284.